package com.lwq.view;

import java.awt.Canvas;
import java.awt.Graphics;
import java.awt.Image;

import com.lwq.cocos.ProjectInfoAdpter;
import com.lwq.util.Constance;
import com.lwq.util.DrawUtil;

public class CenterEditorView extends Canvas {
	private static CenterEditorView instance = null;
	private float mBorderWidth= 108;
	private float mBorderHeight= 35;
	private float mPaintWidth = 800;
	private float mPaintHeight = 480;
	private Image mPhoneFrameImage= null;


	public float getBorderWidth() {
		return mBorderWidth;
	}

	public float getBorderHeight() {
		return mBorderHeight;
	}


	public float getPaintWidth() {
		return mPaintWidth;
	}
	
	public float getPaintHeight() {
		return mPaintHeight;
	}
	

	public void setmPaintWidth(float mPaintWidth) {
		this.mPaintWidth = mPaintWidth;
	}

	public CenterEditorView() {
		init();
		setEvent();
	}

	public static CenterEditorView getInstance() {
		if (instance == null) {
			instance = new CenterEditorView();
		}
		return instance;
	}

	private void init() {
		setScreenSize(800, 480);
	}

	private void setEvent() {

	}

	public void setScreenSize(float width, float height) {
		mPaintWidth = width;
		mPaintHeight = height;
		if(mPaintWidth > mPaintHeight){
			mPhoneFrameImage = DrawUtil.getImage("res/image/draw_phone_frame_rotate.png");
			mBorderWidth = 108;
			mBorderHeight = 35;
		}else{
			mPhoneFrameImage = DrawUtil.getImage("res/image/draw_phone_frame.png");
			mBorderWidth = 35;
			mBorderHeight = 108;
		}
		repaint();
	}

	@Override
	public void paint(Graphics g) {
		if(mPhoneFrameImage != null){
//			DrawUtil.drawImage(g, mPhoneFrameImage, 0, 0, mPhoneFrameImage.getWidth(null), mPhoneFrameImage.getHeight(null));
		}
		if (ProjectInfoAdpter.getInstance().getSelectNode() != null) {
			ProjectInfoAdpter.getInstance().getSelectNode().draw(g);
		}
	}

}
